home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / Arashi 1.1 / Game Source / mtz / mtz src / gdeftest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-31  |  1.8 KB  |  76 lines  |  [TEXT/KAHL]

  1. #include <GestaltEqu.h>
  2. #include "stdio.h"
  3.  
  4. ProcPtr oldGestaltFunction;
  5.  
  6. /* ResetGestalt() will reset the Gestalt selectors to the way they were before         */
  7. /* starting.                                                                        */
  8. void ResetGestalt()
  9. {
  10.     ProcPtr    junk;
  11.     OSErr    myReplaceErr=0;
  12.     Handle    gstFuncHandle;
  13.     int        gstDummyFuncRsrcID = 129;
  14.     int        SAVRTrouble = 130;
  15.     
  16.     if(oldGestaltFunction != 0)
  17.         myReplaceErr = ReplaceGestalt('SAVR', oldGestaltFunction, &junk);
  18.     else
  19.     {
  20.         gstFuncHandle = GetResource('GDEF', gstDummyFuncRsrcID);
  21.         if(gstFuncHandle == 0)
  22.             Alert(SAVRTrouble,0);
  23.         else
  24.         {
  25.             DetachResource(gstFuncHandle);
  26.             myReplaceErr = ReplaceGestalt('SAVR', *gstFuncHandle, &oldGestaltFunction);
  27.         }
  28.     }
  29.     if(myReplaceErr != noErr)
  30.         Alert(130,0);
  31. }
  32.  
  33.  
  34. /* DisableSuperclock will set the Gestalt selector 'savr'     */
  35. /* to indicate that a screen saver, such as afterdark,         */
  36. /* is enabled already, thus superclock will                    */
  37. /* not attempt to draw on the playing surface.                */
  38. void DisableSuperClock()
  39. {
  40.     OSErr    myNewErr, myReplaceErr;
  41.     int        gstFuncRsrcID = 128;
  42.     Handle    gstFuncHandle;
  43.     int        SAVRTrouble = 130;
  44.     
  45.     gstFuncHandle = GetResource('GDEF', gstFuncRsrcID);
  46.     if(gstFuncHandle == 0)
  47.         Alert(SAVRTrouble,0);
  48.     else
  49.     {
  50.         DetachResource(gstFuncHandle);
  51.         myNewErr = NewGestalt('SAVR',*gstFuncHandle);
  52.         if(myNewErr != noErr)
  53.         {
  54.             myReplaceErr = ReplaceGestalt('SAVR', *gstFuncHandle, &oldGestaltFunction);
  55.             if(myReplaceErr != noErr)
  56.                 Alert(SAVRTrouble,0);
  57.         }
  58.     }
  59.     /* DisposHandle(gstFuncHandle); */
  60. }
  61.  
  62. main()
  63. {
  64.     DisableSuperClock();
  65.     printf("Superclock should now be gone \n");
  66.     Alert(130,0);
  67.     ResetGestalt();
  68.     printf("Superclock should now be back \n");
  69.     Alert(130,0);
  70.     DisableSuperClock();
  71.     printf("Superclock should now be gone \n");
  72.     Alert(130,0);
  73.     ResetGestalt();
  74.     printf("Superclock should now be back \n");
  75.     Alert(130,0);
  76. }